/*
times array has to be 1 greater than launches for the time 
to wait after the last launch
*/
enum LMState{ Inactive, Active, Launching, Done };
var currentState = LMState.Inactive;

var times : int[];
var launchers : LaunchObject[];

function FixedUpdate () {
  switch (currentState) {
    case LMState.Active:
        StartCoroutine(Active());
      break;
    
    case LMState.Inactive:
      break;
      
    case LMState.Launching:
      break;
      
    default:
      Debug.Log(currentState);
      Debug.Log("Something went wrong, Incorrect Launcher State");
      break;
  }
}

function Active(){
  currentState = LMState.Launching;
  var count = 0;
  for(launcher in launchers){
    launcher.setState(LauncherState.Active1);
    yield WaitForSeconds (times[count]);
    launcher.launch();
    count++;
  }
  yield WaitForSeconds (times[count]);
  currentState = LMState.Inactive;
}  

function setStateActive(){
  currentState = LMState.Active;
}

function setStateInactive(){
  currentState = LMState.Inactive;
}

function getState(){
  return currentState;
}

function GetTime(){
  var totalTime : int = 0;
  for(time in times){
    Debug.Log("time="+ time);
    totalTime+= time;
  }
  Debug.Log("totalTime "+ totalTime);
  return totalTime;
}
  